<!DOCTYPE html>
<html>
<head>
    <title>档案发放办理</title>
<#include "../common/common.ftl"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row  layui-col-space10">
        <div class="layui-col-xs12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form" id="searchForm">
                        <div class="layui-inline layui-hide-xs">征收项目名称：</div>
                        <div class="layui-inline layui-hide-xs">
                            <select name="search_eq_integer_zsp.id" id="zsProjectSelect">
                                <option value="">--请选择--</option>
                            </select>
                        </div>
                        项目名称：
                        <div class="layui-inline" style="width: 120px;">
                            <input class="layui-input" name="search_like_string_zsp.projectName" autocomplete="off">
                        </div>
                        协议编号：
                        <div class="layui-inline" style="width: 120px;">
                            <input class="layui-input" name="search_like_string_c.contractCode" autocomplete="off">
                        </div>
                        被征收人：
                        <div class="layui-inline" style="width: 120px;">
                            <input class="layui-input" name="search_like_string_c.name" autocomplete="off">
                        </div>
                        选房号：
                        <div class="layui-inline" style="width: 120px;">
                            <input class="layui-input" name="search_like_string_c.chooseHouseNum" autocomplete="off">
                        </div>
                        档案发放状态：
                        <div class="layui-inline" style="width: 120px;">
                            <select name="search_eq_integer_c.daffStatus" id="daffStatusSelect">
                                <option value="">--请选择--</option>
                            </select>
                        </div>
                        交房状态：
                        <div class="layui-inline" style="width: 120px;">
                            <select name="search_eq_integer_c.takeHouseStatus" id="takeHouseStatusSelect">
                                <option value="">--请选择--</option>
                            </select>
                        </div>
                        <button class="layui-btn" type="button" id="searchButton"><i
                                class="layui-icon layui-icon-search"></i>搜索
                        </button>
                    </form>
                    <table id="dataTable" class="layui-table" lay-filter="layFilter"></table>
                    <!--序号-->
                    <script type="text/html" id="indexTpl">
                        {{d.LAY_TABLE_INDEX+1}}
                    </script>
                    <!--菜单-->
                    <script type="text/html" id="dataTable_toolbar">
                        <a class="layui-btn layui-btn-xs jmdf-btn-view" lay-event="dataTable_view"><i
                                class="layui-icon layui-icon-friends"></i>查看</a>
                        {{#if(d.daffStatus == 1){ }}
                        <a class="layui-btn layui-btn-xs jmdf-btn-edit" lay-event="dataTable_edit_daff">
                            <i class="layui-icon layui-icon-edit"></i> 设置为档案已发放</a>
                        {{# } }}
                        {{# if(d.daffStatus == 2){}}
                        <a class="layui-btn layui-btn-xs jmdf-btn-edit" lay-event="dataTable_edit_daff"><i
                                class="layui-icon layui-icon-edit"></i> 设置为档案未发放</a>
                        {{# } }}

                    </script>
                    <!-- 表格头部工具栏 -->
                    <script type="text/html" id="toolbar">
                        <div class="layui-btn-container right">
                            <button lay-event="reload" class="layui-btn layui-btn-sm"><i
                                    class="layui-icon layui-icon-refresh"></i>重载
                            </button>
                        </div>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/modules/' //静态资源所在路径
    }).use(['table', 'form', 'jquery', 'jmdf', 'page', 'dataDict'], function () {
        var $ = layui.jquery, jmdf = layui.jmdf, page = layui.page, table = layui.table, form = layui.form, dataDict = layui.dataDict;

        form.render();
        dataDict.select("档案发放状态", "daffStatusSelect", "");
        dataDict.select("交房状态", "takeHouseStatusSelect", "");

        dataDict.zsProject("zsProjectSelect", "");

        /***********************table表格相关操作 start*************************/
        var tableRenderId = "renderId";
        var tableId = "dataTable";
        var table_layFilter = "layFilter";
        var tableUrl = "loadDaffList";

        //列项内容
        var cols = [[
            {title: "序号", toolbar: '#indexTpl', type: "numbers", fixed: 'left', align: 'center', width: 60}
            , {field: "zsProjectName", title: "征收项目", align: 'center', minWidth: 200}
            , {field: "contractCode", title: "协议编号", align: 'center', minWidth: 150}
            , {field: "name", title: "被征收人", align: 'center', minWidth: 150}
            , {field: "chooseHouseNum", title: "选房号", align: 'center', width: 100}
            , {
                field: "financeSettleStatus", title: "财务结算状态", align: 'center', width: 120, templet: function (d) {
                    return d.financeSettleStatusStr;
                }
            }
            , {
                field: "daffStatus", title: "档案发放状态", align: 'center', width: 120, templet: function (d) {
                    return d.daffStatusStr;
                }
            }
            ,
            {
                field: "daffDate", title: "档案发放日期", align: 'center', width: 120, templet: function (d) {
                return d.daffDate;
            }
            }
            , {title: '操作', fixed: 'right', align: 'center', toolbar: '#dataTable_toolbar', width: 320}
        ]];
        //table设置项
        var options = {
            elem: '#' + tableId//table列表id值
            , url: tableUrl
            , toolbar: '#toolbar'//自定义工具栏
            , cols: cols
            , id: tableRenderId
            , defaultToolbar: ['filter', 'print']//显示列、打印
            , autoSort: false //禁用前端自动排序。
        };

        //初始表格（含分页设置）
        page.render(options);
        //表格排序
        page.sort(tableId, tableRenderId);
        //刷新当前页方法封装
        page.reload();

        //分页查询（查询条件）
        $("#searchButton").click(function () {
            page.search("searchForm", tableRenderId);
        });

        //头工具栏事件
        table.on('toolbar(' + table_layFilter + ')', function (obj) {
            switch (obj.event) {
                case 'reload':
                    loadData();
                    break;
            }
        });

        table.on("tool(" + table_layFilter + ")", function (obj) {
            var data = obj.data;///获得当前行数据
            var layEvent = obj.event;//获得lay-event对应的值
            var id = data["id"];
            if (layEvent == "dataTable_view") {
                jmdf.view("/business/contract/view?contractId=" + id);
            } else if (layEvent == "dataTable_edit_daff") {
                var url = "setDaffStatus?contractId=" + id;
                jmdf.saveOrUpdate("get", url, "");
            }
        });

    });
</script>
</body>
</html>